import Mock from 'mockjs'
// 模拟城市数据, 带百度地图经纬度
const citys =  [
  {
    "code": 110000,
    "lng": "116.402544",
    "name": "北京",
    "english": "Beijing",
    "shorted": "BJ",
    "lat": "39.914492",
    "target": "/"
  },
  {
    "code": 310000,
    "lng": "121.471038",
    "name": "上海",
    "english": "Shanghai",
    "shorted": "SH",
    "lat": "31.244209",
    "target": "/sh/"
  },
  {
    "code": 440300,
    "lng": "114.069562",
    "name": "深圳",
    "english": "Shenzhen",
    "shorted": "SZ",
    "lat": "22.555457",
    "target": "/sz/"
  },
  {
    "code": 330100,
    "lng": "120.185839",
    "name": "杭州",
    "english": "Hangzhou",
    "shorted": "HZ",
    "lat": "30.273821",
    "target": "/hz/"
  },
  {
    "code": 320100,
    "lng": "118.791321",
    "name": "南京",
    "english": "Nanjing",
    "shorted": "NJ",
    "lat": "32.066204",
    "target": "/nj/"
  },
  {
    "code": 510100,
    "lng": "104.078942",
    "name": "成都",
    "english": "Chengdu",
    "shorted": "CD",
    "lat": "30.661176",
    "target": "/cd/"
  },
  {
    "code": 420100,
    "lng": "114.270829",
    "name": "武汉",
    "english": "Wuhan",
    "shorted": "WH",
    "lat": "30.585784",
    "target": "/wh/"
  },
  {
    "code": 440100,
    "lng": "113.265589",
    "name": "广州",
    "english": "Guangzhou",
    "shorted": "GZ",
    "lat": "23.138363",
    "target": "/gz/"
  },
  {
    "code": 120000,
    "lng": "117.226757",
    "name": "天津",
    "english": "Tianjin",
    "shorted": "TJ",
    "lat": "39.13967",
    "target": "/tj/"
  },
  {
    "code": 320500,
    "lng": "120.619907115",
    "name": "苏州",
    "english": "Suzhou",
    "shorted": "SU",
    "lat": "31.317987368",
    "target": "/su/"
  }
]
// 城市列表接口
Mock.mock('/api/citys', () => {
  return {
    code: 200,
    data: citys
  }  
})
// 列表数据
const list = Mock.mock({
  "list|10-20": [{
    "id": '@id',
    "title": '@ctitle',
    "desc": '@cword(10,20)',
    "banners|4-6": ['@image(100x100, @color)'],
  }]
})
// 给列表数据添加位置信息
list.list.forEach(v => {
  v.pos = citys[Math.floor(Math.random() * citys.length)]
})
// 列表接口
Mock.mock('/api/list', () => {
  return {
    code: 200,
    data: list.list
  }
})
// 首页轮播接口
Mock.mock('/api/home/banners', () => {
  const data = Mock.mock({
    "data|4": ['@image(200x200, @color)']
  })

  return {
    code: 200,
    data: data.data
  }
})